package com.zhkj.crawl.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.jsoup.Jsoup;
import org.springframework.http.HttpHeaders;

public class Ocr {

    public static String recognizePy(String url){
        try {
            String reqBody = String.format("{\"url\":\"%s\"}", url);
            String json = Jsoup.connect("http://47.243.19.3/ocr/ocrUrl")
                    .requestBody(reqBody)
                    .header(HttpHeaders.CONTENT_TYPE, "application/json")
                    .post().body().text();
            JSONObject jsonObject = JSON.parseObject(json);
            return jsonObject.getString("result");
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }

    public static void main(String[] args) {
        System.out.println(recognizePy("https://images-na.ssl-images-amazon.com/captcha/xzqdsmvh/Captcha_uxwpssfglr.jpg"));
    }
}
